package com.example.adminvue.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.adminvue.domain.BGoods;
import com.example.adminvue.mapper.BGoodsMapper;
import com.example.adminvue.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
*
*/
@Service
public class BGoodsService
{
    @Autowired
    private BGoodsMapper bGoodsMapper;


    public List<BGoods> selectList(BGoods goods) {
        LambdaQueryWrapper<BGoods> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotEmpty(goods.getGoodsName())){
            queryWrapper.like(BGoods::getGoodsName,goods.getGoodsName());
        }
        List<BGoods> list = bGoodsMapper.selectList(queryWrapper);
        return list;
    }

    public BGoods selectById(Long id) {
        return bGoodsMapper.selectById(id);
    }

    public int insert(BGoods goods) {
        return bGoodsMapper.insert(goods);
    }

    public int update(BGoods goods) {
        return bGoodsMapper.updateById(goods);
    }

    public int deleteById(Long[] id) {
        return bGoodsMapper.deleteGoodsById(id);
    }
}
